package com.example.neusoft215gdh.androidpro_21.Activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.neusoft215gdh.androidpro_21.Common.utilMeth;
import com.example.neusoft215gdh.androidpro_21.JavaBean.BannerView;
import com.example.neusoft215gdh.androidpro_21.JavaBean.ClubCourse;
import com.example.neusoft215gdh.androidpro_21.JavaBean.ClubDetail;
import com.example.neusoft215gdh.androidpro_21.JavaBean.ClubList;
import com.example.neusoft215gdh.androidpro_21.Listener.ClubListener;
import com.example.neusoft215gdh.androidpro_21.Model.ClubModel;
import com.example.neusoft215gdh.androidpro_21.R;

import java.util.ArrayList;
import java.util.List;

import static com.example.neusoft215gdh.androidpro_21.R.drawable.b;

/**
 * Created by hp-pc on 2017/10/16.
 */

public class ClubjianjieActivity extends AppCompatActivity implements ClubListener,utilMeth,View.OnClickListener{
    private int[] imgs = {R.drawable.a, b, R.drawable.c, R.drawable.d};
    private List<View> viewList;
    BannerView bannerView;
    Button club_class,club_video;
    String club_id;
    TextView club_intro1;
    TextView phone;
    TextView time;
    TextView teacher_name;
    TextView teacher_intro;
    ImageView reg;
    String userid;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.club_intro);
        viewList = new ArrayList<View>();
        for (int i = 0; i < imgs.length; i++) {
            ImageView image = new ImageView(this);
            image.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
            //设置显示格式
            image.setScaleType(ImageView.ScaleType.CENTER_CROP);
            image.setImageResource(imgs[i]);
            viewList.add(image);
        }
        bannerView = (BannerView) findViewById(R.id.bannerjianjie);
        bannerView.startLoop(true);
        bannerView.setViewList(viewList);
//        bannerView.setTransformAnim(true);
        initViews();
        Intent intent = getIntent();
        club_id = intent.getStringExtra("club_id");
        System.out.println("Club_id为:-------------------------------------------------"+club_id);
        ClubModel clubModel = new ClubModel();
        clubModel.getClubDetailjianjie(club_id,userid,this);
        reg.setOnClickListener(this);//调用监听
        club_class.setOnClickListener(this);//调用监听
    }

    @Override
    public void initViews() {
        SharedPreferences user=getSharedPreferences("Userid",0);
        userid=user.getString("user_id","");
        club_intro1= (TextView) findViewById(R.id.club_intro2);
        phone= (TextView) findViewById(R.id.phone2);
        time= (TextView) findViewById(R.id.time2);
        reg= (ImageView) findViewById(R.id.reg_return);
        club_class= (Button) findViewById(R.id.club_class);
        club_video= (Button) findViewById(R.id.club_video);
    }

    @Override
    public void onResponse(List<ClubList> bean) {

    }

    @Override
    public void onResponseClubDetailVideo(List<ClubDetail> bean) {

    }

    @Override
    public void onResponseClubDetailjianjie(ClubDetail bean) {
        club_intro1.setText(bean.getIntroduction());//俱乐部简介
        phone.setText(bean.getClub_tel());//联系方式
        time.setText(bean.getOpen_time());//开门时间
    }

    @Override
    public void onResponseClubDetailCourse(ClubCourse bean) {

    }

    @Override
    public void onFail(String msg) {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.reg_return:
                finish();
                break;
            case R.id.club_class:
                Intent ent=new Intent(this,ClubCourseActivity.class);
                ent.putExtra("clubid",club_id);
                startActivity(ent);
                break;

        }
    }
}
